package com.zhaosc.spark.core

import org.apache.spark.SparkConf
import org.apache.spark.SparkContext
import com.zhaosc.spark.java.SortObj

object SecondSort {

  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setMaster("local")
      .setAppName("SecondSort");

    val sc = new SparkContext(conf);
    val weatherRdd = sc.textFile("weather.txt");

    weatherRdd.map(info => {
      val params = info.split("\t")
      val sort=new SortObj(params(1).toInt,params(2).toInt);
      Tuple2(sort,info);
    }).sortByKey(true)
    .foreach(println _)
    
    sc.stop();
  }
}